# 本实例只能在安装了jetson inference的jetson nano ，jetson nx等机器上运行。

import jetson.inference
import jetson.utils
import argparse

# parse the command line
parser = argparse.ArgumentParser()
parser.add_argument("filename", type=str, help="filename of the image to process")
parser.add_argument("--network", type=str, default="models/googlenet", help="model to use, can be:  googlenet, resnet-18, ect.")
parser.add_argument("--labels", type=str, default="models/labels.txt", help="the model labels.")
args = parser.parse_args()

# load an image (into shared CPU/GPU memory)
img = jetson.utils.loadImage(args.filename)
net = jetson.inference.imageNet(argv=["--model=" + args.network, "--labels=" + args.labels,
                                      "--input-blob=input_0", "--output_blob=output_0"])

class_idx, confidence = net.Classify(img)

print("class:{},confidence:{}".format(class_idx, confidence))
